<script>
/**
 * title
 * @return {[type]} [description]
 */
import FileUp from '@/components/fileupPanel'
export default{
	components:{
		FileUp,
		// Player
	},
	props:{

	},
	data(){
		return {
			visible:false,
			data:{},
			sellist:[],
			fileup:{
				file:{},
				filelist:[],
			},
			loading:false,
		}
	},
	created(){
	},
	mounted(){
		// this.$refs.player.show(1);
	},
	methods:{
		send(){
			// 检查对应类型与对应资源和数量是否匹配
			this.$refs.forms.validate().then(async ()=>{
				console.log('验证通过');
				let flist =this.$refs.fileup.urlList();
				if(flist?.length==0){
					this.$message.error('请上传媒体资源');
					return;
				}
				this.loading=true;
				let rs = await this.muajax.YssSave({
					fid:this.data.fid,
					src:flist
				});
				this.loading=false;
				if(rs.status==200){
					this.$message.success(rs.msg);
					this.visible=false;
				}
			}).catch(err=>{
				this.loading=false;
				console.log('验证不通过');
				console.log(err)
				// this.$errorFocus(err);
			})
		},
		show(show,sellist){
			this.visible=show;
			if(show){
				this.fileup.filelist=[];
				this.sellist=sellist
			}
		},
		setchange(){
			this.file.filelist=[];
		},
	},
	computed:{},
	watch:{

	},
	filters:{},
}
</script>
<template>
	<a-modal
		v-model:visible="visible"
		width="800px"
		title="分类管理"
		:maskClosable="false"
		@ok="send"
		cancelText="取消"
		okText="提交"
		:confirmLoading="loading"
	>
		<a-form
		ref="forms"
		:model="data"
		>
			<!-- <div @click="$refs.player.show(true);">123</div> -->
			<a-form-item
				label="分类"
				:labelCol="{span: 4}"
			>
				<a-select
					placeholder="请选择，留空为顶级显示"
					:dropdownMatchSelectWidth="false"
					v-model:value="data.fid"
					:allowClear="true"
				>
					<a-select-option v-for="v in sellist" :key="v.id">{{ v.prefixname }}</a-select-option>
				</a-select>
			</a-form-item>
			<a-form-item
				label="上传资源"
				:labelCol="{span: 4}"
			>
				<FileUp
				ref="fileup"
				:fileup="fileup"
				:api="muajax.api.YscFileup"
				/>
			</a-form-item>
			
		</a-form>
	</a-modal>
	<!-- <Player
		ref="player"
	/> -->
</template>
<style lang="less" scoped>

</style>